/*
Copyright SecureKey Technologies Inc. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

package endpoint

import (
	"git.cloud.inspur.com/ichain/ichain-sdk-go/pkg/common/options"
	"git.cloud.inspur.com/ichain/ichain-sdk-go/pkg/ichain/comm"
	"git.cloud.inspur.com/ichain/ichain-sdk-go/pkg/providers/ichain"
)

type EventEndpoint struct {
	ichain.Inode
	opts []options.Opt
}

func (e *EventEndpoint) Opts() []options.Opt {
	return e.opts
}

// FromInodeConfig 通过inode以及endpoint配置生成事件节点
// @param config
// @param inode
// @param inodeCfg
// @return *EventEndpoint
func FromInodeConfig(config ichain.EndpointConfig, inode ichain.Inode, inodeCfg *ichain.InodeConfig) *EventEndpoint {
	opts := comm.OptsFromInodeConfig(inodeCfg)
	opts = append(opts, comm.WithConnectTimeout(config.Timeout(ichain.InodeConnection)))

	return &EventEndpoint{
		Inode: inode,
		opts:  opts,
	}
}
